#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 3e5 + 5;

int n, m;
char s[N];
int tot;
int tr[N][26], len[N], cnt[N], fail[N], sz, last;

int newnode(int l) {
  len[++sz] = l;
  return sz;
}
void init() {
  s[tot = 0] = '^';
  last = 0;
  sz = -1;
  int node0 = newnode(0);
  int node1 = newnode(-1);
  fail[node0] = node1;
}
int get_fail(int p) {
  while (s[tot - len[p] - 1] != s[tot]) p = fail[p];
  return p;
}
void add(char c) {
  s[++tot] = c;
  int p = get_fail(last);
  int ch = c - 'a';
  if (!tr[p][ch]) {
    int x = newnode(len[p] + 2);
    int y = get_fail(fail[p]);
    fail[x] = tr[y][ch];
    // done last
    tr[p][ch] = x;
  }
  last = tr[p][ch];
  cnt[last]++;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string t;
  cin >> t;
  init();
  for (char c : t) add(c);
  ll ans = 0;
  per(i, sz, 2) {
    ans = max(ans, 1ll * cnt[i] * len[i]);
    cnt[fail[i]] += cnt[i];
  }
  cout << ans;
  return 0;
}